#ifndef _MODELLOADER_H_
#define _MODELLOADER_H_
#include <SEngine/Render/Entity/Model.h>
#include <memory>
#include <string>
// #include <SEngine/Render/Entity/BoundingGraphics.h>
#include <SERender/Resourses/Shader.h>
#include <SECore/ResourcePayload.h>
#include <SEngine/Render/Entity/MeshFilter.h>
#include <SEngine/Render/Entity/MaterialFilter.h>
#include <SEngine/Render/Entity/SDF.h>

struct aiScene;
struct aiNode;
struct aiMesh;
struct aiMaterial;

namespace Assimp { 
    class Importer;
}

namespace SEngine
{
    class ModelLoader 
    {
    public:
        ModelLoader() {}
        ModelLoader(ResRef<Material> material) { m_material = material; }
        virtual ~ModelLoader() = default;
        void Load(const std::string & fileName);
        std::unique_ptr<MeshFilter> ExportMeshFilter();
        std::unique_ptr<MaterialFilter> ExportMaterialFilter();
        std::unique_ptr<SDF> ExportSDF();
    private:
        void ForeachMeshes(std::function<void(const std::string & name, aiMesh * mesh)> && fn);
        void ForeachMaterials(std::function<void(const std::string & name, aiMaterial * material)> && fn);
        glm::vec3 CalcTangent(glm::vec3 normal);
        glm::vec3 CalcBitangent(glm::vec3 normal, glm::vec3 tangent);


    private:
        std::string m_directory;
        ResRef<Material> m_material;
        const aiScene* m_scene;
        std::shared_ptr<Assimp::Importer> m_importer;
    };
} // namespace SEngine

#endif

